var httpSvc = require("./httpSvc");
var cf = require("../utils/config");
var q = require("querystring");
/*
* 请求规范
* @param d  json     请求数据
* @param h  json     请求头
* @param cb function callback函数
*
* */

//招聘主页轮播
exports.getCategoryCarouselList = function(d,h,cb){
    var path =cf.path_recruit+"/getCategoryCarouselList?categoryId="+d.categoryId;
    var opt = httpSvc.makeOpt(cf.server_host,cf.server_port, path, "post");
    httpSvc.httpReq(opt, function (b) {
        if (b.json.code !=0) {
            global.logerror("招聘主页轮播：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + (b.body ));
        } else {
            global.loginfo("招聘主页轮播：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + b.body);
        }
        cb(b)
    }, d);
};
//招聘主页职位列表
exports.getEnterpriseRecruitList = function(d,h,cb){
    var path =cf.path_recruit+"/getEnterpriseRecruitList?"+q.stringify(d);
    var opt = httpSvc.makeOpt(cf.server_host,cf.server_port, path, "post");
    httpSvc.httpReq(opt, function (b) {
        if (b.json.code !=0) {
            global.logerror("招聘主页职位列表：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + (b.body ));
        } else {
            global.loginfo("招聘主页职位列表：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + b.body);
        }
        cb(b)
    }, d);
};
//获取招聘圈子列表
exports.getCategoryCirclesList = function(d,h,cb){
    var path =cf.path_recruit+"/getCategoryCirclesList?"+q.stringify(d);
    var opt = httpSvc.makeOpt(cf.server_host,cf.server_port, path, "post");
    httpSvc.httpReq(opt, function (b) {
        if (b.json.code !=0) {
            global.logerror("获取招聘圈子列表：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + (b.body ));
        } else {
            global.loginfo("获取招聘圈子列表：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + b.body);
        }
        cb(b)
    }, d);
};
//招聘搜索历史
exports.recruitSearchHistory = function(d,h,cb){
    var path =cf.path_recruit+"/recruitSearchHistory?"+q.stringify(d);
    var opt = httpSvc.makeOpt(cf.server_host,cf.server_port, path, "post");
    httpSvc.httpReq(opt, function (b) {
        if (b.json.code !=0) {
            global.logerror("招聘搜索历史：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + (b.body ));
        } else {
            global.loginfo("招聘搜索历史：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + b.body);
        }
        cb(b)
    }, d);
};
//搜索职位
exports.searchRecruit = function(d,h,cb){
    var path =cf.path_recruit+"/searchRecruit?"+q.stringify(d);
    var opt = httpSvc.makeOpt(cf.server_host,cf.server_port, path, "post");
    httpSvc.httpReq(opt, function (b) {
        if (b.json.code !=0) {
            global.logerror("搜索职位：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + (b.body ));
        } else {
            global.loginfo("搜索职位：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + b.body);
        }
        cb(b)
    }, d);
};
//招聘职位详情
exports.getRecruitInfo = function(d,h,cb){
    var path =cf.path_recruit+"/getRecruitInfo?"+q.stringify(d);
    var opt = httpSvc.makeOpt(cf.server_host,cf.server_port, path, "post");
    httpSvc.httpReq(opt, function (b) {
        if (b.json.code !=0) {
            global.logerror("招聘职位详情：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + (b.body ));
        } else {
            global.loginfo("招聘职位详情：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + b.body);
        }
        cb(b)
    }, d);
};
//招聘-职位企业信息
exports.getEnterpriseRecruitListById = function(d,h,cb){
    var path =cf.path_recruit+"/getEnterpriseRecruitListById?"+q.stringify(d);
    var opt = httpSvc.makeOpt(cf.server_host,cf.server_port, path, "post");
    httpSvc.httpReq(opt, function (b) {
        if (b.json.code !=0) {
            global.logerror("职位企业信息：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + (b.body ));
        } else {
            global.loginfo("职位企业信息：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + b.body);
        }
        cb(b)
    }, d);
};
//获取个人信息
exports.getUserInfo = function(d,h,cb){
    var path =cf.path_recruit+"/getUserInfo?"+q.stringify(d);
    var opt = httpSvc.makeOpt(cf.server_host,cf.server_port, path, "post");
    httpSvc.httpReq(opt, function (b) {
        if (b.json.code !=0) {
            global.logerror("获取个人信息：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + (b.body ));
        } else {
            global.loginfo("获取个人信息：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + b.body);
        }
        cb(b)
    }, d);
};
//修改个人信息
exports.updateUserData = function(d,h,cb){
    var path =cf.path_recruit+"/updateUserData?"+q.stringify(d);
    var opt = httpSvc.makeOpt(cf.server_host,cf.server_port, path, "post");
    httpSvc.httpReq(opt, function (b) {
        if (b.json.code !=0) {
            global.logerror("修改个人信息：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + (b.body ));
        } else {
            global.loginfo("修改个人信息：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + b.body);
        }
        cb(b)
    }, d);
};
//投递职位
exports.deliveryRecruitInfo = function(d,h,cb){
    var path =cf.path_recruit+"/deliveryRecruitInfo?"+q.stringify(d);
    var opt = httpSvc.makeOpt(cf.server_host,cf.server_port, path, "post");
    httpSvc.httpReq(opt, function (b) {
        if (b.json.code !=0) {
            global.logerror("投递职位：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + (b.body ));
        } else {
            global.loginfo("投递职位：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + b.body);
        }
        cb(b)
    }, d);
};
//删除搜索历史
exports.deleteSearchHistory = function(d,h,cb){
    var path =cf.path_recruit+"/deleteSearchHistory?"+q.stringify(d);
    var opt = httpSvc.makeOpt(cf.server_host,cf.server_port, path, "post");
    httpSvc.httpReq(opt, function (b) {
        if (b.json.code !=0) {
            global.logerror("删除搜索历史：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + (b.body ));
        } else {
            global.loginfo("删除搜索历史：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + b.body);
        }
        cb(b)
    }, d);
};
//清空搜索历史
exports.emptySearchHistory = function(d,h,cb){
    var path =cf.path_recruit+"/emptySearchHistory?"+q.stringify(d);
    var opt = httpSvc.makeOpt(cf.server_host,cf.server_port, path, "post");
    httpSvc.httpReq(opt, function (b) {
        if (b.json.code !=0) {
            global.logerror("清空搜索历史：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + (b.body ));
        } else {
            global.loginfo("清空搜索历史：" + JSON.stringify(opt) + " .posts. " + JSON.stringify(d) + " .back. " + b.body);
        }
        cb(b)
    }, d);
};